package commands;

import com.amazonaws.services.s3.AmazonS3;
import jesss.commands.JesssCommand;
import jesss.commands.JesssCommandFactoryImpl;
import jesss.options.JesssOptions;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.*;

/**
 * User: Lee
 * Date: 8/21/13
 * Time: 11:20 PM
 */
public class DeleteBucketCommandTests extends CommandTestsBase {

    private AmazonS3 mockS3 = mock(AmazonS3.class);
    private JesssOptions mockJesssOptions = mock(JesssOptions.class);

    @Before
    public void Setup() {
        stub(mockJesssOptions.getAmazonS3()).toReturn(mockS3);
        stub(mockJesssOptions.getCommandName()).toReturn("db");
    }

    @Test
    public void CanDeleteBucket() throws Exception {

        String[] args = new String[2];
        args[0] =  "-bn";
        args[1] = "blah";

        JesssCommand deleteBucketCommand = JesssCommandFactoryImpl.getInstance().createCommand(mockS3, mockJesssOptions.getCommandName(), mockJesssOptions.getShouldDisplayVerbose(), args);

        deleteBucketCommand.executeCommand();
        verify(mockS3).deleteBucket(anyString());
        verify(mockS3, times(1)).deleteBucket("blah");
    }


}
